06. Creating Objects Using References
Creating Objects Using References
Code Used in Video
using System.Collections;
using UnityEngine;
public class ObjectMaker : MonoBehaviour {
public GameObject objectToCreate;
// Use this for initialization
void Start() {
// make an object
Object.Instantiate(objectToCreate, new Vector3(2, 4, 6), Quaternion.identity);
}
// Update is called once per frame
void Update() {
}
}
Tip: Do not copy/paste code, typing it out will help you learn faster.
Recommended Reading
- Unity Scripting API: Object.Instantiate
- Unity Scripting API: Vector3
- Unity Scripting API: Quaternion